package com.dididoctor.doctor.Activity.Usercentre.Evaluate;

import android.content.Context;

import com.dididoctor.doctor.Activity.ConstantValue;
import com.dididoctor.doctor.Bean.Token;
import com.dididoctor.doctor.Http.MyHttpResponseHandler;
import com.dididoctor.doctor.MV.BasePresenter;
import com.dididoctor.doctor.MV.BusinessClient;
import com.dididoctor.doctor.MV.Response;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;

/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： EditPhonePresenter
 * @包名称： com.dididoctor.patient.Activity.Usercentre.Userinfo
 * @创建人： 李营
 * @创建时间：2016/4/20 18:55
 * @修改人：
 * @修改时间：2016/4/20 18:55
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class EvalutePresenter extends BasePresenter {

    private EvalutaeView view;

    public EvalutePresenter(Context context, EvalutaeView view) {
        super(context, view);
        this.view = view;
    }

    public void getEvalutate() {
        RequestParams params = new RequestParams();
        params.put("userId", Token.getUserId());
        params.put("token",Token.getToken());
        BusinessClient.post(ConstantValue.evalute, params, new MyHttpResponseHandler() {

            @Override
            public void onMyResponse(Response response) {
                if (response.isSucceed()) {

                    String satisfied = response.getString("good");
                    String commonly = response.getString("common");
                    String dissatisfied = response.getString("bad");
                    view.setData(satisfied,commonly,dissatisfied);

                } else {
                    view.showToastMessage("获取数据失败，请稍后再试");
                    view.setData("0","0","0");
                }
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                view.showToastMessage("加载数据失败,请稍后重试");
            }
        });
    }

}
